package com.aaa.ssm.service.Impl;

import com.aaa.ssm.entity.StudentDTO;
import com.aaa.ssm.entity.StudentVO;
import com.aaa.ssm.mapper.StudentMapper;
import com.aaa.ssm.query.StudentQuery;
import com.aaa.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper Mapper;



    @Override
    public Integer deleteStudent(Integer id) {
        int i = Mapper.deleteStudentById(id);
        return i;
    }

    @Override
    public Map<String, Object> queryStudent(StudentQuery studentQuery) {
       //查询当前页的信息
        List<StudentDTO> students = Mapper.listCurrentPageData(studentQuery);
        //查询总数量
        Long totalCount = Mapper.getTotalCount(studentQuery);
        HashMap<String, Object> map = new HashMap<>();
        map.put("currentData",students);
        map.put("totalCount",totalCount);
        return map;
    }

    @Override
    public Integer addstudent(StudentDTO studentDTO) {
        int i = Mapper.addStudent(studentDTO);
        return i;

    }

    @Override
    public StudentDTO getStudentById(Integer id) {
        return Mapper.getStudentById(id);
    }

    @Override
    public Integer updateStudent(StudentVO studentDTO) {
        return Mapper.updateStudent(studentDTO);
    }


}
